<section class="main-content">
    <div class="main-content__inner">

        <div class="main-content__left">
            <h1 class="global-small-title">Корзина</h1>
            <table class="global-table">
                <thead>
                    <tr class="center">
                        <th>&nbsp;</th>
                        <th>Наименование</th>
                        <th>Цена</th>
                        <th>Количество</th>
                        <th>Общая стоимость</th>
                        <th>&nbsp;</th>
                    </tr>
                </thead>
                <tbody class="goods__list center list">
                    <?php foreach ($products as $product): ?>
                        <tr class="availability _item">
                            <td>
                                <div class="global-photo">
                                    <a href="/<?php echo $product['url']; ?>">
                                        <img alt="<?php echo $product['name']; ?>" src="<?php
                                        $src = file_exists(Yii::app()->basePath . '/../images/products/' . $product['image']) ? Yii::app()->request->baseUrl . '/images/products/' . $product['image'] : Yii::app()->request->baseUrl . '/images/articles/no_photo.jpg';
                                        echo $src;
                                        ?>">
                                    </a>
                                </div>
                            </td>
                            <td>
                                <a class="global-table__link" href="/<?php echo $product['url'] ?>"><?php echo $product['name'] ?></a>
                            </td>
                            <td>
                                <span class="global-table__price"><?php echo $product['price'] ?><span class="currency">c</span></span>
                            </td>
                            <td>
                                <div class="number__counter">
                                    <div class="number__counter__fewer remove-f-b"><span>-</span></div>
                                    <div class="number__counter__result">
                                        <input type="text" data-t="<?php echo $product['t'] ?>" value="<?php echo $product['quantity']; ?>">
                                    </div>
                                    <div class="number__counter__more add-f-b"><span>+</span></div>
                                </div>
                            </td>
                            <td>
                                <span class="global-table__price"><?php echo ($product['price'] * $product['quantity']); ?><span class="currency">c</span></span>
                            </td>
                            <td>
                                <a class="global-table__delete _delProd" data-id="<?php echo $product['id'] ?>" href="#"><span>Удалить</span></a>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
            <ul class="order-info">
                <li>
                    <dl>
                        <dt>Итого:</dt>
                        <dd id="total-p">0<span class="currency">i</span></dd>
                    </dl>
                </li>
                <li>
                    <p>Номер вашего заказа: <strong>#<?php echo $orderPrefix; ?></strong></p>
                    <p>Вы можете проконсультироваться со специалистом просто позвонив и назвав номер заказа.</p>
                </li>
            </ul>
            <br>
            <ul class="order-info">
                <li style="width: 250px;">
                    <dl style=" line-height: 25px;">
                        <dt>Итоговая сумма с доставкой:</dt>
                        <dd id="itogo">1100<span class="currency">i</span></dd>
                    </dl>
                </li>
            </ul>
            <?php
            $form = $this->beginWidget('CActiveForm', array(
                'id' => 'order-form',
                'action' => '/order',
                'enableAjaxValidation' => true,
                'clientOptions' => array(
                    'validateOnSubmit' => true,
                ),
            ));
            ?>
            <div style="display: none">
                <?php echo $form->error($model, 'name'); ?>
                <?php echo $form->error($model, 'phone'); ?>
                <?php echo $form->error($model, 'email'); ?>
                <?php echo $form->error($model, 'method'); ?>
                <?php echo $form->error($model, 'warehouse'); ?>
                <?php echo $form->error($model, 'shipping'); ?>
            </div>
            <fieldset>
                <h3 class="product-info__title">        
                    <span>Для оформления заказа просим заполнить необходимые данные</span>
                </h3>
                <ul class="order-form__list">
                    <li>
                        <div class="order-form__list__item">
                            <label for="name">Имя получателя *</label>
                            <div class="type-text">
                                <?php echo $form->textField($model, 'name', array('class' => 'jqueryPlaceholder')); ?>                                                   
                            </div>                                               
                        </div>
                    </li><br>
                    <li>
                        <div class="order-form__list__item">
                            <label for="mail">Электронная почта *</label>
                            <div class="type-text">
                                <?php echo $form->textField($model, 'email', array('class' => 'jqueryPlaceholder')); ?>                                                
                            </div>                                                      
                        </div>
                    </li><br>
                    <li>
                        <div class="order-form__list__item">
                            <label for="phone">Телефон *</label>
                            <div class="type-text">
                                <?php echo $form->textField($model, 'phone', array('class' => 'jqueryPlaceholder masked-phone')); ?>                                          
                            </div>                                              
                        </div>
                    </li><br>                        
                </ul>
            </fieldset>
            <fieldset class="order-form__item">
                <h3 class="middle-title">Способ доставки:</h3>
                <ul class="order-form__list-type-radio">
                    <li>                        
                        <label data-type="courier">                            
                            <?php
                            echo $form->radioButton($model, 'method', array(
                                'value' => 'deliv',
                                'checked' => 'checked',
                                'uncheckValue' => null
                            ));
                            ?>
                            <b>Курьером в день заказа</b>
                            <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;сегодня
                        </label>
                    </li>
                    <li> 
                        <label data-type="self">
                            <?php
                            echo $form->radioButton($model, 'method', array(
                                'value' => 'ship',
                                'uncheckValue' => null
                            ));
                            ?>
                            <b>Самовывозом</b><br>
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;бесплатно, сегодня
                        </label>                        
                    </li>
                </ul>
            </fieldset>
            <fieldset class="order-form__item">                
                <ul class="order-form__list">
                    <li style="display: none;" id="deliv">
                        <div>                       
                            <div id="courier" class="select">
                                <?php echo $form->dropDownList($model, 'warehouse', CHtml::listData(Wares::model()->findAll('wh_region = ' . $region['id']), 'wh_id', 'wh_title'), array('empty' => 'Выберите адрес самовывоза')); ?>                    
                            </div>                                                      
                        </div>
                    </li>
                    <li id="ship">
                        <div>                       
                            <div id="courier" class="textarea">
                                <?php echo $form->textarea($model, 'shipping', array('class' => 'jqueryPlaceholder', 'placeholder' => 'Адрес доставки', 'rows' => 10, 'cols' => 45, 'style' => 'width:100%;')); ?>                    
                            </div>                                                      
                        </div>
                    </li>
                </ul>
            </fieldset>
            <fieldset>
                <input type="submit" value="Подтвердить заказ" name="yt0" class="order-form__button">            
            </fieldset>
            <?php $this->endWidget(); ?>
        </div>        
    </div>
</section>
<style>
    .order-form__list-type-radio li {
        float: left;
    }
</style>
<script>
    $("input[type='radio']").change(function () {
        if (this.value == 'deliv') {
            $('#ship').show();
            $('#deliv').hide();
        }
        else if (this.value == 'ship') {
            $('#deliv').show();
            $('#ship').hide();
        }
    });
</script>